define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'cla.classification/index',
        add_url: 'cla.classification/add',
        edit_url: 'cla.classification/edit',
        delete_url: 'cla.classification/delete',
        export_url: 'cla.classification/export',
        modify_url: 'cla.classification/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh','add'],
                cols: [[
                    {field: 'sort', width: 80, title: '排序', edit: 'text',search: false},
                    {field: 'title', minWidth: 80, title: '分类名称'},
                    {field: 'status', title: '状态',selectList: {0: '正常',1: '禁用'}},
                    {field: 'create_time', title: '添加时间',search: false},
                    {field: 'update_time', title: '更新时间',search: false},
                    {width: 250, title: '操作', templet: ea.table.tool},
                //     {width: 250,title: '操作', templet: function (d) {
                //         if(d.status == 0){
                //             return '<a class="layui-btn layui-btn-normal layui-btn-xs"  data-request="cla.classification/modify?id='+d.id+'" data-title="确定禁用吗？" data-table="currentTableRenderId">禁用</a>'+
                //             '<button class="layui-btn layui-btn-xs layui-btn-success" data-open="cla.classification/edit?id='+d.id+'"  data-title="编辑">编辑</button>'+
                //             '<button class="layui-btn layui-btn-xs layui-btn-danger" data-request="cla.classification/delete?id='+d.id+'"  data-title="确定删除吗？" >删除</button>';
                //         }else{
                //             return '<a class="layui-btn layui-btn-sm layui-btn-xs"  data-request="cla.classification/modifyq?id='+d.id+'" data-title="确定启用吗？" data-table="currentTableRenderId">启用</a>'+
                //             '<button class="layui-btn layui-btn-xs layui-btn-success" data-open="cla.classification/edit?id='+d.id+'"  data-title="编辑">编辑</button>'+
                //             '<button class="layui-btn layui-btn-xs layui-btn-danger" data-request="cla.classification/delete?id='+d.id+'"  data-title="确定删除吗？" >删除</button>';
                //         }
                //     }
                // },
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});